s = input('введите скобочную последовательность:')
s1 = s2= ''
k = 0
for i in range(len(s)):
    if s[i] in '({[<>]})':
        s1=s1+s[i]
for i in range(len(s1)):
    if s1[i] in '([{<':
        s2 = s2 + s1[i]
    elif len(s2) > 0 and s1[i] == ')' and s2[-1] == '(':
        s2 = s2[:-1]
    elif len(s2) > 0 and s1[i] == ']' and s2[-1] == '[':
        s2 = s2[:-1]    
    elif len(s1) > 0 and s1[i] == '}' and s2[-1] == '{':
        s2 = s2[:-1]
    elif len(s2) > 0 and s1[i] == '>' and s2[-1] == '<':
        s2 = s2[:-1]
    else:
        k += 1
        break
    print(s2)
    
if s2 == '' and k == 0:
    print('True')
else:
    print('False')